package com.ethink.platform.controller.system;

import com.ethink.framework.common.web.BaseController;
import com.ethink.framework.common.web.response.CommonResponse;
import com.ethink.system.api.SystemApiAuthorityFacade;
import com.ethink.system.api.info.SystemApiAuthorityInfo;
import com.ethink.system.api.request.SystemApiAuthorityAddRequest;
import com.ethink.system.api.request.SystemApiAuthorityQueryRequest;
import com.ethink.system.api.request.SystemApiAuthorityUpdateRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统接口权限表 Controller
 *
 * @author default
 * @date 2022-09-26
 */
@Tag(name = "SystemApiAuthorityController", description = "系统接口权限表 Controller")
@RestController
@Slf4j
@RequestMapping("platform-server/v1/system-service")
public class SystemApiAuthorityController extends BaseController {

    @Autowired
    private SystemApiAuthorityFacade systemApiAuthorityFacade;

    @Operation(summary = "分页查询")
    @GetMapping("/systemApiAuthority/pageQuery")
    public CommonResponse<List<SystemApiAuthorityInfo>> pageQuerySystemApiAuthority(SystemApiAuthorityQueryRequest request) {
        return succeedWithPage(systemApiAuthorityFacade.getSystemApiAuthorityList(request));
    }

    @Operation(summary = "根据Id查询")
    @GetMapping("/systemApiAuthority/get/{systemApiAuthorityId}")
    public CommonResponse<SystemApiAuthorityInfo> getSystemApiAuthorityById(@PathVariable("systemApiAuthorityId") Long systemApiAuthorityId) {
        return succeedWith(systemApiAuthorityFacade.getSystemApiAuthorityById(systemApiAuthorityId));
    }

    @Operation(summary = "新增")
    @PostMapping("/systemApiAuthority/add")
    public CommonResponse addSystemApiAuthority(@RequestBody SystemApiAuthorityAddRequest request) {
        systemApiAuthorityFacade.addSystemApiAuthority(request);
        return succeed();
    }

    @Operation(summary = "修改")
    @PutMapping("/systemApiAuthority/update")
    public CommonResponse updateSystemApiAuthority(@RequestBody SystemApiAuthorityUpdateRequest request) {
        systemApiAuthorityFacade.updateSystemApiAuthority(request);
        return succeed();
    }

    @Operation(summary = "删除")
    @PutMapping("/systemApiAuthority/get/{systemApiAuthorityId}")
    public CommonResponse deleteSystemApiAuthority(@PathVariable("systemApiAuthorityId") Long systemApiAuthorityId) {
        systemApiAuthorityFacade.deleteSystemApiAuthority(systemApiAuthorityId);
        return succeed();
    }

}